package mt;
import java.util.*;
import java.util.Scanner;
public class Main4_0820 {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n=cin.nextInt();
        int m=cin.nextInt();
        int[] nums1=new int[n];
        int[] nums2=new int[m];
        for(int i=0;i<n;i++){
            nums1[i]=cin.nextInt();
        }
        for(int i=0;i<m;i++){
            nums2[i]=cin.nextInt();
        }
        long[][] dp=new long[n+1][m+1];
        for(int i=1;i<=n;i++){
            dp[i][0]=dp[i-1][0]+Math.abs(nums1[i-1]);
        }
        for (int i=1;i<=m;i++){
            dp[0][i]=dp[0][i-1]+Math.abs(nums2[i-1]);
        }
        for(int i=1;i<=n;i++){
            for (int j=1;j<=m;j++){
                if (nums1[i-1]==nums2[j-1]){
                    dp[i][j]=dp[i-1][j-1];
                }else {
                    dp[i][j]=Math.min(
                            Math.min(dp[i-1][j-1]+Math.abs(nums2[j-1]-nums1[i-1]),Math.abs(nums1[i-1])+dp[i-1][j]),
                            Math.abs(nums2[j-1])+dp[i][j-1]);
                }
            }
        }
        System.out.println(dp[n][m]);
    }

}
